/*
 * Licensed to the Tai Ping Jin Ke
 *
 * Copyright (c) 2022 .
 * All rights reserved.
 * 项目名称：呼叫中心-通用处理层-任务调度
 * 版权说明：本软件属太平金融科技服务(上海)有限公司所有，在未获得太平金融科技服务(上海)有限公司正式授权情况下，任何企业和个人，不能获取、阅读、安装、传播本软件涉及的任何受知识产权保护的内容。
 */
package com.taiping.cc.job.converter;

import cn.hutool.core.util.IdUtil;
import com.taiping.cc.application.constant.dao.ConfigStatusEnum;
import com.taiping.cc.application.constant.service.PlatformServiceEnum;
import com.taiping.cc.job.dataobject.HttpRequestConfigDO;
import com.taipingframework.utility.exception.ManagerException;
import com.taipingframework.utility.http.ServiceConfigInfo.ServiceRequestConfigInfo;

public class HttpRequestConfigConverter {

    /**
     * ServiceRequestConfigInfo 数据传输对象 转 HttpRequestConfigDO 数据对象
     */
    public static HttpRequestConfigDO convert(PlatformServiceEnum serviceConstant, ServiceRequestConfigInfo requestConfigInfo) throws ManagerException {
        HttpRequestConfigDO requestConfig = new HttpRequestConfigDO();
        requestConfig.setRequestId(IdUtil.objectId());
        requestConfig.setPlatformCode(serviceConstant.getPlatformCode());
        requestConfig.setPlatformName(null);
        requestConfig.setServiceCode(serviceConstant.getServiceCode());
        requestConfig.setServiceName(null);
        requestConfig.setRequestMethod(requestConfigInfo.getRequestMethod());
        requestConfig.setServiceUrl(requestConfigInfo.getRequestUrl());
        requestConfig.setMediaType(requestConfigInfo.getContentType());
        requestConfig.setJsonBody(requestConfigInfo.getRequestBody());
        requestConfig.setConfigStatus(ConfigStatusEnum.ENABLE.getCode());
        requestConfig.setRemark(null);
        BaseDataObjectConverter.convert(requestConfig);
        return requestConfig;
    }

}
